﻿#region FileHeader
//////////////////////////////////////////////////////////////////////////////////
// Author:                          Hector Llanos
// Date:                            03.19.2011
// FileName:                        CBulletBase.cs
// Reason:                          base weapon class
//////////////////////////////////////////////////////////////////////////////////
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Base;
using Run_Game;
using Globals;
using MessagingSystem;
using Microsoft.Xna.Framework.Content;

namespace Objects
{
    public class CBulletBase : CBase
    {
        private CBase m_pOwner;
        private int m_nDamage;

        public int Damage
        {
            get { return m_nDamage; }
            set { m_nDamage = value; }
        }

        public CBase Owner
        {
            get { return m_pOwner; }
            set { m_pOwner = value; }
        }

        public CBulletBase() : base(Game1.Instance.Content, "SpriteSheets/bullet", 5, 1, 10)
        {
            Type = type.BASEBULLET;
            Speed = 100f;
            Animtion.Depth = 1f;
        }

        public CBulletBase(ContentManager content, string assetName, int nMaxDirX, int nMaxDirY, int nFrameDuration) : base(content, assetName, nMaxDirX, nMaxDirY, nFrameDuration)
        {

        }
        public override void Update(float fElapsedTime)
        {
            Animtion.UpdateFrame(fElapsedTime);
            base.Update(fElapsedTime);

            if (Position.X + Width / 2 > CGlobal.Screenwidth)
                Game1.Instance.MessageSystem.SendMessage(new CDestroyBulletMessage(this));
            if (Position.X < 0)
                Game1.Instance.MessageSystem.SendMessage(new CDestroyBulletMessage(this));

            if (Position.Y < 0)
                Game1.Instance.MessageSystem.SendMessage(new CDestroyBulletMessage(this));

            if (Position.Y + Height / 2 > CGlobal.Screenheight)
                Game1.Instance.MessageSystem.SendMessage(new CDestroyBulletMessage(this));
        }
        public override void Render()
        {
            Animtion.DrawFrame(Game1.Instance.SpriteBatch, Position);
        }
    }
}
